let selectFile = function(){
    let fileInput = document.getElementById('fileInput');
    let file = fileInput.file;
    //store origin file into db
    let fileObj = {
        id:1,
        file:file,
    };
    oridb.put(fileObj,function (err,result) {
        if (!err){
            alert("上传成功");
        }
    });
    //deal it with tf.js
    deal();
    fileInput.click();
};

let upload = function () {
    middb.allDocs({include_docs:true,descending:false},function (err,docs) {
       if (err){
           alert("ERROR");
       }else{
           let formData = new FormData();
           formData.append('file',docs);
           let xhr = new XMLHttpRequest();
           xhr.responseType = 'blob';//expected file input

           //some function that might be used
           xhr.onreadystatechange = function(){
             if (xhr.readyState===4&&xhr.status===200){
                 alert("你的演示文稿已经制作完毕，确认以继续");
                 window.location.href = "./download.html";
             }else{
                 console.log("Connect to Server error")
             }
           };
           //上传进度调用方法实现

           xhr.open("POST",'http://localhost:80/upload');
           xhr.send(formData);
       }
    });
};